package com.ruoyi.reim.listener;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.reim.domain.WorkflowReim;
import com.ruoyi.reim.service.WorkflowReimService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.Expression;


/**
 * <p>报销监听器</p>
 * <p>创建日期：2021-07-17</p>
 *
 * @author zhou-qf
 */
public class WorkflowListener implements ExecutionListener {

    private Expression state;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        WorkflowReim workflowReim = new WorkflowReim();
        workflowReim.setId(delegateExecution.getProcessInstanceBusinessKey());
        workflowReim.setState(state.getValue(delegateExecution).toString());
        SpringUtils.getBean(WorkflowReimService.class).updateWorkflowReim(workflowReim);
    }
}
